package cac.fenjian.resource.AoTask.MsAoMatchBill.service;

import cac.fenjian.resource.AoTask.MsAoMatchBill.dao.MsAoMatchBillDao;
import cac.fenjian.resource.AoTask.MsAoMatchBill.dto.MsAoMatchBillDTO;
import com.cac.dme.adapter.rest.msg.QueryReqBean;
import com.cac.dme.adapter.rest.msg.QueryRespBean;
import com.cac.dme.adapter.utils.PageHelper;
import com.cac.dme.common.exception.service.DaoException;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * @program test-curd
 * @description AO物料配套清单服务
 * @author: LSL
 * @create: 2022-08-29-15-54
 **/
@Service
public class MsAoMatchBillService {
    @Autowired
    private MsAoMatchBillDao msAoMatchBillDao;

    /**
     * 分页查询AO物料配套清单服务数据
     *
     * @param queryReqBean
     * @return
     */
    public QueryRespBean<HashMap> searchByPage(QueryReqBean<HashMap> queryReqBean) {
        QueryRespBean<HashMap> queryRespBean = new QueryRespBean<>();
        try {
            PageHelper.startPage(queryReqBean.getPageParameter());
            HashMap searchParams = queryReqBean.getSearchParams();
            Page<HashMap> dataList = msAoMatchBillDao.searchMsAoMatchBillByPage(searchParams);
            queryRespBean.setResult(dataList);
            return queryRespBean;
        } catch (Exception e) {
            throw new DaoException(e.getMessage());
        }
    }

    /**
     * 分页查询AO物料未配套清单
     * @param queryReqBean
     * @return
     */
    public QueryRespBean<HashMap> searchMsAoMatchBill(QueryReqBean<HashMap> queryReqBean, String msTaskPackageId) {
        QueryRespBean<HashMap> queryRespBean = new QueryRespBean<>();
        try {
            PageHelper.startPage(queryReqBean.getPageParameter());
            Page<HashMap> dataList = msAoMatchBillDao.searchMsAoMatchBill(msTaskPackageId);
            queryRespBean.setResult(dataList);
            return queryRespBean;
        } catch (Exception e) {
            throw new DaoException(e.getMessage());
        }
    }
}
